<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/manage/system/pageBase.jsp" %>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro"%>
<%@ page info="新闻管理" %>

<style>
    table {
        table-layout: fixed; /* 只有定义了表格的布局算法为fixed，下面td的定义才能起作用。 */
        width:100%;
    }

    td {
        word-break: keep-all; /* 不换行 */
        white-space: nowrap; /* 不换行 */
        overflow: hidden; /* 内容超出宽度时隐藏超出部分的内容 */
        text-overflow: ellipsis; /* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用*/
    }

</style>
<form action="<%=path %>/manage/news" method="post">
    <div style="height:auto!important;height:550px;min-height:550px;">
        <h3 style="border-bottom: 1px solid #D7D7D7;color: #666666;font-size: 28px;padding-bottom: 20px;margin-bottom: 30px;">
            <%=getServletInfo()%>
            <shiro:hasPermission name="news:toAdd">
            <a href="toAdd" class="btn btn-primary"
               style="padding: 2px 15px;float:right;">
                <i class="icon-plus "></i>添加新闻
            </a>
            </shiro:hasPermission>
        </h3>
        <div class="filter">
            <div style="float: left">
                <input type="text" value="${e.newstitle}" class="input-medium search-query" name="newstitle" placeholder="新闻标题"/>

                <select id="isshow" name="isshow">
                    <option value="">是否首页推荐</option>
                    <option value="1" <c:if test="${e.isshow eq '1'}"> selected="selected"</c:if>  >是</option>
                    <option value="0"  <c:if test="${e.isshow eq '0'}"> selected="selected"</c:if> >否</option>
                </select>

                <td  style="width: 126px; height: 30px">
                    <input type="text" class="Wdate" id="d1" name="starttime" value="<%=request.getParameter("starttime")==null?"":request.getParameter("starttime")%>" onFocus="var d2=$dp.$('d2');WdatePicker({onpicked:function(){d2.focus();},maxDate:'#F{$dp.$D(\'d2\')}'})" />
                </td>
                至
                <td  style="width: 126px; height: 30px">
                    <input type="text" class="Wdate" id="d2" name="endtime" value="<%=request.getParameter("endtime")==null?"":request.getParameter("endtime")%>" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d1\')}'})"/>
                </td>

                <button method="selectList" class="btn btn-info" style="padding:0px 5px;margin-top: -4px;"
                        onclick="selectList(this)">
                    <i class="icon-search"></i>查询
                </button>

            </div>
        </div>
        <table class="table table-bordered table-hover table-striped" >
            <tr >
                <th width="5%">序号</th>
                <th width="10%">新闻标题</th>
                <th width="10%">发布日期</th>
                <th width="10%">缩略图</th>
                <th width="10%">是否首页推荐</th>
                <th width="30%">新闻内容</th>
                <th width="10%">新闻关联链接</th>
                <th width="10%" align="center">操作</th>
            </tr>
            <c:forEach var="item" items="${pager.list}">
                <tr>
                    <td>${item.id}</td>
                    <td>${item.newstitle}</td>
                    <td>${item.pushtime}</td>
                    <td><a href="<%=SystemManage.getInstance().getSystemSetting().getImageRootPath()%>${item.newsimgurl}" target="_blank">
                        <img  src="<%=SystemManage.getInstance().getSystemSetting().getImageRootPath()%>${item.newsimgurl}" width="20px" height="20px"></a></td>
                    <td>
                        <c:choose>
                            <c:when test="${item.isshow eq '0'}">
                                否
                            </c:when>
                            <c:otherwise>
                                是
                            </c:otherwise>
                        </c:choose>
                    </td>
                    <td>${item.newscontent}</td>
                    <td>${item.newsrelationurl}</td>
                    <td>
                        <shiro:hasPermission name="news:toEdit">
                        <a href="toEdit?id=${item.id}">编辑</a>&ensp;
                        </shiro:hasPermission>
                        <shiro:hasPermission name="news:toDel">
                        <a href="toDel?id=${item.id}">删除</a>
                        </shiro:hasPermission>
                    </td>
                </tr>
            </c:forEach>
            <tr>
                <td colspan="71" style="text-align: center;">
                    <%@ include file="/manage/system/page.jsp" %>
                </td>
            </tr>
        </table>
    </div>
</form>

<script type="text/javascript" src="<%=path%>/resource/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
    $(function () {
        //日期框
        $('.date-picker').datepicker({
            autoclose: true,
            startDate:new Date(),//只要加上此代码即可

            todayHighlight: true
        });
        //点击日历图标弹出日期框
        $('#starttime').datepicker().next().on(ace.click_event, function () {
            $(this).prev().focus();
        });
        $('#endtime').datepicker().next().on(ace.click_event, function () {
            $(this).prev().focus();
        });
        $('#editable-select').editableSelect({
            effects: 'default',
            duration: 200,
        });
    });

    // $(function () {
    //     $("#firstCheckbox").on("click", function () {
    //         if ($(this).prop("checked")) {
    //             $("input[type=checkbox]").prop("checked", true);
    //         } else {
    //             $("input[type=checkbox]").prop("checked", false);
    //         }
    //     });
    // });
    function submitIDs(obj, tip) {
        if ($("input:checked").size() == 0) {
            alert("请先选择要操作的内容！");
            return false;
        }

        if (confirm(tip)) {
            //createMark();
            var _form = $("form");
            _form.attr("action", $(obj).attr("method"));
            _form.submit();
        }
        return false;
    }
    //查询
    function selectList(obj) {

        var _form = $("form");
        _form.attr("action", $(obj).attr("method"));
        _form.submit();
    }
</script>
<%@ include file="/manage/system/baseFoot.jsp" %>
